using ClassicalCiphers
using Base.Test

@test (encrypt_enigma("AAA", [1,2,3], "AAA") == "BDZ")
@test (decrypt_enigma("BDZ", [1,2,3], "AAA") == "aaa")

@test (encrypt_enigma("AAA", [1,2,3], "ABC") == "CXT")
@test (decrypt_enigma("CXT", [1,2,3], "ABC") == "aaa")

@test (encrypt_enigma("AAA", [1,2,3], "ABC", ring="AAA", reflector_id='B', stecker="") == "CXT")
@test (decrypt_enigma("CXT", [1,2,3], "ABC", ring="AAA", reflector_id='B', stecker="") == "aaa")

@test (encrypt_enigma("AAA", [1,2,3], "ABC", ring="AAA", reflector_id="YRUHQSLDPXNGOKMIEBFZCWVJAT", stecker="") == "CXT")
@test (decrypt_enigma("CXT", [1,2,3], "ABC", ring="AAA", reflector_id="YRUHQSLDPXNGOKMIEBFZCWVJAT", stecker="") == "aaa")

@test (encrypt_enigma("AAA", [1,2,3], "ABC", ring="AAA", reflector_id='B', stecker=Tuple{Char, Char}[]) == "CXT")
@test (decrypt_enigma("CXT", [1,2,3], "ABC", ring="AAA", reflector_id='B', stecker=Tuple{Char, Char}[]) == "aaa")

@test encrypt_enigma("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", [1,2,3], "AAA") == "BDZGOWCXLTKSBTMCDLPBMUQOFXYHCXTGYJFL"
@test decrypt_enigma("BDZGOWCXLTKSBTMCDLPBMUQOFXYHCXTGYJFL", [1,2,3], "AAA") == "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

@test (stecker = [('P','O'), ('M','L'), ('I','U'), ('K','J'), ('N','H'), ('Y','T'), ('G','B'), ('V','F'), ('R','E'), ('D','C')];
	   encrypt_enigma("ABCDEF", [1,2,3], "AAA", stecker=stecker) == "GWKGRC")
@test (stecker = [('P','O'), ('M','L'), ('I','U'), ('K','J'), ('N','H'), ('Y','T'), ('G','B'), ('V','F'), ('R','E'), ('D','C')];
	   decrypt_enigma("GWKGRC", [1,2,3], "AAA", stecker=stecker) == "abcdef")

@test (encrypt_enigma("there are fifteen possible answers to this question",
					   [1,2,3],
					   "UQI") == "SPPBXWOFVOEAKDRFKLDOLYHKSNTFBPERQFZCDTRAKXCE")
@test (decrypt_enigma("SPPBXWOFVOEAKDRFKLDOLYHKSNTFBPERQFZCDTRAKXCE",
					   [1,2,3],
					   "UQI") == "therearefifteenpossibleanswerstothisquestion")

@test (encrypt_enigma("AAAAAAAA", [1,2,3], "UQI") == "OWLDUWEL")
@test (decrypt_enigma("OWLDUWEL", [1,2,3], "UQI") == "aaaaaaaa")

@test (encrypt_enigma("AAAAAAAA", [1,2,3], "UQI", stecker="") == "OWLDUWEL")
@test (decrypt_enigma("OWLDUWEL", [1,2,3], "UQI", stecker="") == "aaaaaaaa")

@test (encrypt_enigma("AAAAAAAA", [1,2,3], "AAA", ring="AAB") == "UBDZGOWC")
@test (decrypt_enigma("UBDZGOWC", [1,2,3], "AAA", ring="AAB") == "aaaaaaaa")

@test (encrypt_enigma("AAAA", [1,2,3], "UQI", ring="EFG") == "YHKD")
@test (decrypt_enigma("YHKD", [1,2,3], "UQI", ring="EFG") == "aaaa")

@test (encrypt_enigma("when shall we three meet again", [1,2,3], "yev", ring="aaa", stecker="POMLIUKJNHYTGBVFREDC") == "PDTTELKJEYFAQZCHRWVREXFFK")

@test (encrypt_enigma("when shall we three meet again", [5,1,4], "yev", ring="aaa", stecker="POMLIUKJNHYTGBVFREDC") == "TSJKKEKWKLFPOCKAXUVSDWVOW")

@test (encrypt_enigma("WHENSHALLWETHREEMEETAGAIN", [5, 1, 4], "yev", ring="aac", stecker="POMLIUKJNHYTGBVFREDC") == "AVYFURCOELTCLFMZGABKOWDKH")

@test (encrypt_enigma("WHENSHALLWETHREEMEETAGAIN", [5, 1, 4], "yev", ring="aab", stecker="POMLIUKJNHYTGBVFREDC") == "OIXYQZDEWUHADNZKXBUGZZNQW")

@test (encrypt_enigma("WHENSHALLWETHREEMEETAGAIN", [5, 1, 4], "yev", ring="nqz", stecker="POMLIUKJNHYTGBVFREDC") == "GDCTXXBEIGWEMLLUDNUXZJDKU")

@test (encrypt_enigma("AAA", [1,2,3], "QEV") == "LNP")

@test (plain = "WHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAIN";
	ans = "TSJKKEKWKLFPOCKAXUVSDWVOWSSDCKBGJDNBJYWZPOFKMSMQKMFQVZKGHFWHWEMKXLELAXRRNHWLCBXAQWUEPVEVXWGPMDVNXLHLBGLALOYQKLMKOJBWWOMUGXNPCZRLQDMWRCDNNENKNGGYBYOUMQNFKJPMQANZLRAJIGDABYMWGYWQZVILLMSQAPQGPZLHXKLGMZEMJJYJGAYCTHRVAKRJNXWHFLOARTZICGUODQTNPBMTGXOHIUBIDXNVBZVWSGSHVVGFHKRUWQCKMLKZEUAZDHUUFPPKKOFIDSIPNGVOLYFCWZYVKPGJPTHLVJPUNRNUTUTKYGZYHCEZIOAMCCUJNEPWKGZNMOBMCKHVWJLZGFZHUHTPBLGTVDIKKDVUVCWWOYAXNQWUROBHHYWSHSPUULKPUVAOLTVZWNRVOEEREEXHYOVKRBZIKCWKPVYUATVPDZUNJPMNDXIKQHPVNBDWEERCBBSABVEQOMGEPJWIOMVEVLKZXORJCYYDELDYKKJIZSBVNTTJEYPNSYKMAJKZIFVDQPHJOBHTTDZBLZMLTPTLHDPKWHSWAGVIEUADKUFRSFYSAOUGIZWWYZPXEOQJXXXFXSQZGDBEGNRDIPVXNVVGWMEFMHYVHMHURIVNINPRQWYEDG";
	encrypt_enigma(plain, [5, 1, 4], "yev", ring="aaa", stecker="POMLIUKJNHYTGBVFREDC") == ans)

@test (plain = "WHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAINWHENSHALLWETHREEMEETAGAIN";
	ans = "UGVATRLVMDBJBTUUVZOJZRICCJPJVKLZTHIMVRDRTWTSGWLWGBLPRDITLGEUWIJQCDQKZXFTCYYNJSBMLBPWQSNWJUFJKHSDRDEQCZHVXLECUNQENXFCLJJHYXULFHZQLYQPGBBHDQLUJKUXFPHGVKSPRDWFGXJYXFGCVHNODSZRSSHQTLUXTHJEZAXKYFRYWWNEJQDJUFFPASFEHOGETXSVVIWKKITUWALMTWCPGZLKOSJYDFUJHUYCSHMFBPMKVYRNQDEBQFQTFJKYIBTNLMQAQLDAMLAIJKGVGVWLBQOCPOQJXQYYUCXVEXPIHOGMDFUYCJCOIKDZIHHAJYAKHXRBHYANVKMQSXVYCTAKUNPPHSTKPEDFQUXAQSQZNLXWDNXLJTFLBWBQNZMKLUJKNUEARFIXAFLMVNRZMMGEHGFLZONEJQMUCXYZBJLNJSZTZMPAVVIJJMDQOJRXYOAFHINLKNFPASLEPKUHRMKXTNOBLSPXMPQSISGJLXBEXSOYCOVLESCHDASAWKKMWDXGNMTJBLWBKGMGXEDCJMICXKIBCBKUOQNPRUGTIUVODQVPKRGWWQWTYLIPCRSNUBHJWQBXCGNCYJRNGNCYZIMXHNHNZPTSEFRYQPAGJJOTXVMMKQLSMGBJNW";
	encrypt_enigma(plain, [5, 1, 4], "yev", ring="ezk", stecker="POMLIUKJNHYTGBVFREDC") == ans)
